#include <QMessageBox>
#include <QtDebug>

#include "dbase.h"
#include "ui_dbase.h"

DBase::DBase(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DBase)
{
    ui->setupUi(this);
}

DBase::~DBase()
{
    delete ui;
}

int DBase::getGroupId(QString grpName)
{
    QSqlQuery query;
    query.exec("SELECT \"GROUP_ID\" FROM \"V_GROUP\" WHERE group_name = '"+grpName+"'");

    qDebug() << query.lastQuery();

    query.first();
    return query.value(0).toInt();
}

int DBase::getMenId(QString TeacherFIO)
{
    QSqlQuery query;
    query.exec("SELECT \"teacher_id\" FROM \"V_TEACHER\" WHERE teacher_fio = '"+TeacherFIO+"'");

    qDebug() << query.lastQuery();

    query.first();
    return query.value(0).toInt();
}
